<!DOCTYPE html>
<!--[if IE 8]> <html lang="zh-CN" class="ie8"> <![endif]-->
<html lang="zh-CN">

<head>
	<meta charset="utf-8" />
	<title>登录 - 用户中心</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link type="text/css" rel="stylesheet" href="css/common.css">
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/common.js"></script>
	<script type="text/javascript" src="js/login.js"></script>
	<link type="text/css" rel="stylesheet" href="css/login.css">
	<link type="text/css" rel="stylesheet" href="css/color-style.css" />
	<script type="text/javascript" src="js/layer.js"></script>
	<script type="text/javascript" src="js/jquery.method.js"></script>
	<script type="text/javascript" src="js/placeholder.js"></script>
	<script type="text/javascript" src="js/jquery.supersized.min.js"></script>

	<script type="text/javascript" src="js/plugins/vue/dist/vue.js"></script>
	<script type="text/javascript" src="js/plugins/axios/dist/axios.js"></script>
	<script src="/js/axios.common.js"></script>
    <script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/jquery.cookie.js"></script>
</head>

<body>
<div class="header login-header w990">
	<div class="logo-info">
		<a href="./" class="logo">
			<img src="css/mall_logo_0.png" />
		</a>
		<span class="findpw">欢迎登录</span>
	</div>
</div>
<div class="login-content">
	<div class="login-banner" style="background: url('css/login-banner.jpg') center;">
		<div class="w990 pos-r">

			<div id="14849678895bBEJL" class="login-form">
				<div class="login-con pos-r">

					<div class="login-wrap" id="login-wrap">

						<div class="login-tit">
							还没有账号？
							<a href="http://www.itsource.cn/register.html" class="regist-link color">
								立即注册
								<i>&gt;</i>
							</a>
						</div>

						<div class="login-radio">
							<ul>
								<li class="active" id="login2" onclick="setTab('login',2,2)">普通登录</li>
								<li class="" id="login1" onclick="setTab('login',1,2)">动态密码登录</li>
							</ul>
						</div>
						<!-- 普通登录 star -->

						<div id="con_login_2" class="form">
							<form id="form2" action="/login.html" method="POST">
								<input type="hidden" name="_csrf" value="X3YzS2VmZWoHDlt8IR4uEwo.bBRWMww8CS4GDFQ3MBBnMnQECyldHQ==">
								<div class="form-group item-name">
									<!-- 错误项标注 给div另添加一个class值'error' star -->
									<div class="form-control-box">
										<i class="icon"></i>
										<input type="text" v-model="formParams.phone" id="username" name="LoginModel[username]" value="" class="text" tabindex="1" placeholder="已验证手机/邮箱/用户名" autocomplete="off" />
									</div>

									<!-- 错误项标注 给div另添加一个class值'error' end -->
								</div>
								<div class="form-group item-password">
									<div class="form-control-box">
										<i class="icon"></i>
										<input type="password" v-model="formParams.password" id="password" name="LoginModel[password]" value="" class="text" tabindex="2" placeholder="密码" autocomplete="off" />
									</div>

								</div>

								<div class="safety">

									<label for="remember">
										<input type="checkbox" value="1" name="remember" id="remember" class="checkbox" />
										<span>自动登录</span>
									</label>

									<a class="forget-password fr" href="http://www.itsource.cn/user/find-password.html">忘记密码？</a>
								</div>
								<div class="login-btn">
									<input type="hidden" name="act" value="act_login" />
									<input type="hidden" name="back_act" value="" />
									<input type="button" @click="submitLogin" name="submit" class="btn-img btn-entry bg-color" id="loginsubmit" value="立即登录" />
								</div>
								<div class="item-coagent">

									<a href="javascript:void(0);" data-id="pc_weixin" class="website-login">
										<i class="weixin"></i>
									</a>

									<a href="javascript:void(0);" data-id="qq" class="website-login">
										<i class="qq"></i>
									</a>

									<a href="javascript:void(0);" data-id="weibo" class="last website-login">
										<i class="sina"></i>
									</a>

								</div>
								<input type="hidden" name="back_url" value="http://www.itsource.cn/register/mobile.html" />

							</form>
						</div>
						<!-- 普通登录 end -->
						<!-- 动态登录 star -->

						<div id="con_login_1" class="form" style="display: none;">
							<form id="form1" action="/login.html" method="POST">
								<input type="hidden" name="_csrf" value="X3YzS2VmZWoHDlt8IR4uEwo.bBRWMww8CS4GDFQ3MBBnMnQECyldHQ==">
								<div class="form-group item-name">
									<!-- 错误项标注 给div另添加一个class值'error' star -->
									<div class="form-control-box">
										<i class="icon"></i>
										<input type="text" id="mobile" name="SmsLoginModel[mobile]" class="text" value="" tabindex="1" placeholder="已注册的手机号码" autocomplete="off" />
									</div>

									<!-- 错误项标注 给div另添加一个class值'error' end -->
								</div>

								<div class="form-group form-group-spe captcha" id="o-authcode">
									<div class="form-control-box">
										<i class="icon"></i>
										<input type="text" id="captcha_sms" name="SmsLoginModel[captcha]" class="text" tabindex="2" placeholder="验证码" />
										<label class="captcha"> <img id="captcha_sms-image" class="captcha-image" src="img/captcha.html" alt="点击换图" title="点击换图" style="vertical-align: middle; cursor: pointer;"><script data-captcha-id='captcha_sms-image' type='text'>{"refreshUrl":"\/site\/captcha.html?refresh=1","hashKey":"niiCaptcha\/site\/captcha"}</script></label>
									</div>

								</div>

								<div class="form-group form-group-spe form-group-phonecode">
									<div class="form-control-box fl">
										<i class="icon"></i>
										<input type="text" id="smsCaptcha" name="SmsLoginModel[smsCaptcha]" class="text" tabindex="3" placeholder="动态密码" />
										<a id="btn_send_sms_code" href="javascript:void(0);" class="phonecode">获取手机动态验证码</a>
									</div>

								</div>

								<div class="safety">
									<label for="remember">
										<input type="checkbox" id="remember" name="SmsLoginModel[remember]" class="checkbox" value="0" />
										<span>自动登录。</span>
									</label>
								</div>

								<div class="login-btn">
									<input type="hidden" name="act" value="act_login" />
									<input type="hidden" name="back_act" value="" />
									<input type="submit" name="submit" class="btn-img btn-entry bg-color" id="loginsubmit" value="立即登录" />
								</div>
								<div class="item-coagent">

									<a href="javascript:void(0);" data-id="qq" class="website-login">
										<i class="qq"></i>
									</a>

									<a href="javascript:void(0);" data-id="pc_weixin" class="website-login">
										<i class="weixin"></i>
									</a>

									<a href="javascript:void(0);" data-id="weibo" class="last website-login">
										<i class="sina"></i>
									</a>

								</div>
								<input type="hidden" name="back_url" value="http://www.itsource.cn/register/mobile.html" />

							</form>
						</div>
						<!-- 动态登录 end -->
					</div>

				</div>
			</div>

			<!-- 验证码脚本 -->
			<script type="text/javascript" src="js/jquery.captcha.js"></script>
			<!-- 表单验证 -->
			<script type="text/javascript" src="js/jquery.validate.js"></script>
			<script type="text/javascript" src="js/jquery.validate.custom.js"></script>
			<script type="text/javascript" src="js/messages_zh.js"></script>
			<script id="client_rules" type="text/javascript">
				[{
					"id": "loginmodel-username",
					"name": "LoginModel[username]",
					"attribute": "username",
					"rules": {
						"required": true,
						"messages": {
							"required": "请输入用户名"
						}
					}
				}, {
					"id": "loginmodel-password",
					"name": "LoginModel[password]",
					"attribute": "password",
					"rules": {
						"required": true,
						"messages": {
							"required": "请输入密码"
						}
					}
				}, {
					"id": "loginmodel-username",
					"name": "LoginModel[username]",
					"attribute": "username",
					"rules": {
						"string": true,
						"messages": {
							"string": "用户名必须是一条字符串。",
							"maxlength": "用户名长度必需在100以内"
						},
						"maxlength": 50
					}
				}, {
					"id": "loginmodel-password",
					"name": "LoginModel[password]",
					"attribute": "password",
					"rules": {
						"string": true,
						"messages": {
							"string": "密码必须是一条字符串。",
							"maxlength": "密码长度必需在32以内"
						},
						"maxlength": 32
					}
				}, {
					"id": "loginmodel-rememberme",
					"name": "LoginModel[rememberMe]",
					"attribute": "rememberMe",
					"rules": {
						"boolean": {
							"trueValue": "1",
							"falseValue": "0"
						},
						"message": {
							"boolean": "记住用户名密码的值必须要么为\"1\"，要么为\"0\"。"
						}
					}
				}, ]
			</script>
			<script id="sms_client_rules" type="text/javascript">
				[{
					"id": "smsloginmodel-mobile",
					"name": "SmsLoginModel[mobile]",
					"attribute": "mobile",
					"rules": {
						"required": true,
						"messages": {
							"required": "请输入手机号码"
						}
					}
				}, {
					"id": "smsloginmodel-smscaptcha",
					"name": "SmsLoginModel[smsCaptcha]",
					"attribute": "smsCaptcha",
					"rules": {
						"required": true,
						"messages": {
							"required": "请输入动态密码"
						}
					}
				}, {
					"id": "smsloginmodel-mobile",
					"name": "SmsLoginModel[mobile]",
					"attribute": "mobile",
					"rules": {
						"match": {
							"pattern": /^13[0-9]{1}[0-9]{8}$|15[0-9]{1}[0-9]{8}$|18[0-9]{1}[0-9]{8}$|17[0-9]{1}[0-9]{8}$|14[0-9]{1}[0-9]{8}$/,
							"not": false,
							"skipOnEmpty": 1
						},
						"messages": {
							"match": "请输入一个有效的手机号码"
						}
					}
				}, {
					"id": "smsloginmodel-rememberme",
					"name": "SmsLoginModel[rememberMe]",
					"attribute": "rememberMe",
					"rules": {
						"boolean": {
							"trueValue": "1",
							"falseValue": "0"
						},
						"message": {
							"boolean": "记住用户名密码的值必须要么为\"1\"，要么为\"0\"。"
						}
					}
				}, {
					"id": "smsloginmodel-captcha",
					"name": "SmsLoginModel[captcha]",
					"attribute": "captcha",
					"rules": {
						"required": true,
						"messages": {
							"required": "请输入图片验证码"
						}
					}
				}, {
					"id": "smsloginmodel-captcha",
					"name": "SmsLoginModel[captcha]",
					"attribute": "captcha",
					"rules": {
						"captcha": {
							"hash": 427,
							"hashKey": "niiCaptcha/site/captcha",
							"caseSensitive": false
						},
						"messages": {
							"captcha": "验证码不正确。"
						}
					}
				}, ]
			</script>
			<script type="text/javascript">
				$().ready(function() {

					//二维码、PC登录切换
					$('.qrcode-target').click(function() {
						if($(this).hasClass('btn-qrcode')) {
							$(this).removeClass('btn-qrcode').addClass('btn-login').attr('title', '去电脑登录');
							$('.login-wrap').hide();
							$('.login-mobile').show();
							return;
						}
						if($(this).hasClass('btn-login')) {
							$(this).removeClass('btn-login').addClass('btn-qrcode').attr('title', '去手机扫码登录');
							$('.login-wrap').show();
							$('.login-mobile').hide();
						}
					});

					$("body").on('click', '.website-login', function() {
						var type = $(this).data("id");
						$.go("http://www.itsource.cn" + "/website/login?type=" + type);
					})

					var container = $("#14849678895bBEJL");

					/**
					 * 初始化validator默认值
					 */
							//先获取到默认函数，不能直接覆盖掉
					var errorPlacement = $.validator.defaults.errorPlacement;
					$.validator.setDefaults({
						errorPlacement: function(error, element) {
							$(element).parent(".form-control-box").addClass("error");
							errorPlacement.call(this, error, element);
						},
						// 失去焦点验证
						onfocusout: function(element) {
							$(element).valid();
						},
						// 成功后移除错误提示
						success: function(error) {
							var error_id = $(error).attr("id");
							var element_id = $(error).attr("for");
							// 移除错误样式
							$("[id='" + error_id + "']").remove();
							$(":input[id='" + element_id + "']").parent(".form-control-box").removeClass("error");
						}
					});

					var validator = $(container).find("#form2").validate();
					// 验证规则，此验证规则会影响编辑器中JavaScript的的格式化操作
					$.validator.addRules($("#client_rules").html());

					$(container).find("#form2").submit(function() {

						if(!validator.form()) {
							return false;
						}
						return true;
					});

					var validator1 = $(container).find("#form1").validate();
					// 验证规则，此验证规则会影响编辑器中JavaScript的的格式化操作
					$.validator.addRules($("#sms_client_rules").html());

					$(container).find("#form1").submit(function() {
						if(!validator1.form()) {
							return false;
						}
						return true;
					});

					$(container).find("#btn_send_sms_code").click(function() {

						if($(this).prop("disabled") == true || $(this).data("doing") == true) {
							return;
						}

						var mobile_valid = $("#mobile").valid();
						var captcha_valid = true;
						if($("#captcha_sms").size() > 0) {
							captcha_valid = $("#captcha_sms").valid();
						}

						if(mobile_valid && captcha_valid) {

							var target = this;

							$(this).data("doing", true);

							var mobile = $("#mobile").val();

							$.post('/site/sms-captcha', {
								mobile: mobile,
								captcha: $("#captcha_sms").val()
							}, function(result) {
								if(result.code == 0) {
									// 开始倒计时
									countdown(target, "获取手机动态验证码");
								} else {
									// 失败后点击验证码
									if($("#captcha_sms-image").size() > 0) {
										$("#captcha_sms").val("");
										$("#captcha_sms-image").click();
									}
									var errors = {};
									errors["SmsLoginModel[" + result.data + "]"] = result.message;
									validator1.showErrors(errors);
								}
								$(target).data("doing", false);
							}, "json");
						}

					});

					var wait = 60;

					function countdown(obj, msg) {
						obj = $(obj);

						if(wait <= 0) {
							obj.prop("disabled", false);
							obj.html(msg);
							wait = 60;
						} else {
							if(msg == undefined || msg == null) {
								msg = obj.html();
							}
							obj.prop("disabled", true);
							obj.html(wait + "秒后重新获取");
							wait--;
							setTimeout(function() {
								countdown(obj, msg)
							}, 1000)
						}
					}
				});
			</script>

		</div>
	</div>
</div>

<!-- 底部 -->
<div class="site-footer">

	<div class="footer-desc-copyright">

		<p class="footer-ecscinfo">
			<a href="#">首页</a>
			|

			<a href="#">隐私保护</a>
			|

			<a href="#">联系我们</a>
			|

			<a href="#">免责条款</a>
			|

			<a href="#">公司简介</a>
			|

			<a href="#">意见反馈</a>

			|
			<a rel="nofollow" target="_blank" href="#">会员登录</a>
			|
			<a rel="nofollow" target="_blank" href="http://bbs.itsource.cn/">会员论坛</a>
			|
			<a href="javascript:;" rel="nofollow">客服热线028-86261949</a>
		</p>
		<p class="footer-otherlink">
			<a title="源码商城" target="_blank" href="http://itsource.cn">源码商城</a>

			|

			<a title="菁鱼课堂" target="_blank" href="http://www.itsource.cn">菁鱼课堂</a>

			|

			<a title="资讯速递" target="_blank" href="http://www.itsource.cn">资讯速递</a>

			|

			<a title="快递查询" target="_blank" href="http://m.kuaidi100.com">快递查询</a>

			|

			<a title="论坛" target="_blank" href="http://bbs.itsource.com/forum.php">会员论坛</a>

			|

			<a title="源代码教育咨询有限公司" target="_blank" href="http://www.itsource.cn">源代码教育咨询有限公司</a>

		</p>

		<p class="footer-beian"> ICP备案证书号:
			<a rel="nofollow" target="_blank" href="#">蜀ICP备88888888号-1</a>
			<a rel="nofollow" target="_blank" href="#"><i></i>蜀公网安备 45323525326664号</a>
		</p>
		<p class="footer-Copyright">Copyright &copy; 2017
			<a target="_blank" style="margin:0;padding:0;" href="http://www.saodangzu.com/">itsource.cn</a> All Rights Reserved. </p>
		<p>&nbsp;</p>

		<p class="footer-fp-img">
			<a target="_blank" href="#"><img src="img/test/kxwz.png"></a>
			<a target="_blank" href="#"><img src="img/test/smyz.png"></a>
			<a target="_blank" href="#"><img src="img/test/cxyz.jpg"></a>
			<a target="_blank" href="#"><img src="img/test/hyyz.png"></a>
			<a target="_blank" href="#"><img src="img/test/jpfw.png"></a>
		</p>
	</div>

</div>
<!-- 底部 _end-->

</body>
<script src="/js/axios.common.js"></script>
<script>
	axios.defaults.baseURL = "http://127.0.0.1:3010/services"; //配置前缀
	Vue.prototype.$http = axios; //给Vue这个类添加一个原型的属性,这个类的对象都能调用
	Vue.config.productionTip = false;
	$().ready(function() {
		new Vue({
			el:"#login-wrap",
			data(){
				return {
					formParams:{
						phone:'13330964748',
						password:'123'
					}
				}
			},
			methods:{
				submitLogin:function () {
                    var param = {
                        username:this.formParams.phone,
                        password:this.formParams.password,
                        type:1
                    };
                    //发起请求 http://localhost:1020/hrm/  auth/auth/oauth/token?
                    this.$http.post("/auth/loginUser/login",param).then(res=>{
                        //获取到Token
                        if(res.data.success) {
                            var token = res.data.resultObj.access_token;
                            var refresh_token = res.data.resultObj.refresh_token;

                            $.cookie('U-TOKEN',token,{
                                expires:7,
                                path:'/',
                                domain:'hrm.com',
                                secure:false
                            });
                            $.cookie('R-TOKEN',refresh_token,{
                                expires:7,
                                path:'/',
                                domain:'hrm.com',
                                secure:false
                            });

                            localStorage.setItem("user", '{"username":"' + this.formParams.phone + '"}');
                            //修改登录成功后跳转到首页
                            alert("登录成功");
                            location.href="http://course.hrm.com:6002/list.html";
                            return;
                        }else{
                            alert("登录失败:"+ajaxResult.message);
                        }
                    }).catch(error => {
                        alert("登录失败:"+ajaxResult.message);
                        return;
                    });
				}
			},
			// mounted(){
             //    //模拟ajax请求访问资源---------------------------------------
             //    this.$http.get("/user/vipUser/list",this.formParams).then(res=>{
             //        console.log(res);
             //    });
			// }
		});
	});

</script>
</html>